<!--
 * @Date: 2021-03-12 21:20:30
 * @名称: 
 * @版本: 0.01
 * @作者: 初雪桜
 * @邮箱: 202184199@qq.com
 * @最后编辑: 初雪桜
 * @LastEditTime: 2021-03-17 23:56:58
 * @FilePath: /Site/app/useradmin/view/SiteSetting/Site/SystemSetting.html
-->
<html>

<head>
    <meta charset="UTF-8" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>网站后台管理模版</title>
    <script src="/public/static/admin/imgupdate/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/admin.css" />
    <script src="/public/static/other.js"></script>
    <script src="/public/static/tisp.js"></script>
    <style>
        .layui-form-label {
            width: 120;
        }
    </style>
</head>

<body>
    <div class="page-content-wrap">
        <form name="form-body" class="layui-form">
            <div class="layui-tab" style="margin: 0">
                <div class="layui-input-block" style="text-align: center;">
                    <div class="layui-box layui-upload-button">
                        <div name="sever_adds">
                            <input type="radio" name="mail-service" value="0" data-mail-port="587"
                                data-mail-address="smtp.mail.me.com" title="苹果邮箱" />
                            <div class="layui-unselect layui-form-radio layui-form-radioed">
                                <i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                <span>苹果邮箱</span>
                            </div>
                            <input type="radio" name="mail-service" value="1" data-mail-port="587"
                                data-mail-address="smtp.qq.com" title="QQ邮箱" />
                            <div class="layui-unselect layui-form-radio">
                                <i class="layui-anim layui-icon"></i>
                                <span>QQ邮箱</span>
                            </div>
                            <input type="radio" name="mail-service" value="2" data-mail-port="465"
                                data-mail-address="smtp.163.com" title="163邮箱" />
                            <div class="layui-unselect layui-form-radio">
                                <i class="layui-anim layui-icon"></i>
                                <span>163邮箱</span>
                            </div>
                            <input type="radio" name="mail-service" value="2" data-mail-port="465"
                                data-mail-address="smtp1.example.com" title="Google邮箱" />
                            <div class="layui-unselect layui-form-radio">
                                <i class="layui-anim layui-icon"></i>
                                <span>Google邮箱</span>
                            </div>
                            <input type="radio" name="mail-service" value="2" data-mail-port="465"
                                data-mail-address="smtp.139.com" title="Google邮箱" />
                            <div class="layui-unselect layui-form-radio">
                                <i class="layui-anim layui-icon"></i>
                                <span>139邮箱</span>
                            </div>
                            <input type="radio" name="mail-service" value="3" data-mail-port="" data-mail-address=""
                                title="自定义" checked="" />
                            <div class="layui-unselect layui-form-radio">
                                <i class="layui-anim layui-icon"></i>
                                <span>自定义</span>
                            </div>
                        </div>

                    </div>

                </div>
                <div class="layui-tab-content">
                    <label class="layui-form-label" title="选择smtp服务器地址">服务器地址：</label>
                    <div class="layui-input-block">

                        <div style="display: flex;" class="layui-box layui-upload-button">

                            <div style="width: 100%;">
                                <input type="text" id="smtp-address" lay-verify="required"
                                    placeholder="Sha512加密密钥不可为空 不可逆" autocomplete="off" class="layui-input"
                                    value="{$smtpSeverHost}">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-tab-content">
                    <label class="layui-form-label" title="设置邮件内容的编码">邮件的编码：</label>
                    <div class="layui-input-block">

                        <div style="display: flex;" class="layui-box layui-upload-button">

                            <div>
                                <div class="layui-inline">
                                    <select name="smtpSeverBodyChar" lay-verify="required" lay-search="">
                                        <option value="">带搜索的选择框</option>
                                        {if $smtpSeverBodyChar == "UTF-8" }
                                        <option selected value="UTF-8">UTF-8</option>
                                        {else /}
                                        <option value="UTF-8">UTF-8</option>
                                        {/if}

                                        {if $smtpSeverBodyChar == "GB2312" }
                                        <option selected value="GB2312">GB2312</option>
                                        {else /}
                                        <option value="GB2312">GB2312</option>
                                        {/if}

                                        {if $smtpSeverBodyChar == "GBK" }
                                        <option selected value="GBK">GBK</option>
                                        {else /}
                                        <option value="GBK">GBK</option>
                                        {/if}

                                        {if $smtpSeverBodyChar == "Big5" }
                                        <option selected value="Big5">Big5</option>
                                        {else /}
                                        <option value="Big5">Big5</option>
                                        {/if}

                                        {if $smtpSeverBodyChar == "Unicode" }
                                        <option selected value="Unicode">Unicode</option>
                                        {else /}
                                        <option value="Unicode">Unicode</option>
                                        {/if}

                                        {if $smtpSeverBodyChar == "Base64" }
                                        <option selected value="Base64">Base64</option>
                                        {else /}
                                        <option value="Base64">Base64</option>
                                        {/if}

                                    </select>
                                </div>
                            </div>

                            <div class="layui-input-block">
                                <label class="layui-form-label" title="是否启用smtp验证">启用SMTP验证：</label>
                                <input disabled type="checkbox" checked="" name="cache" lay-skin="switch"
                                    lay-filter="switchTest" lay-text="ON|OFF">
                                <div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
                                    <em>ON</em><i></i>
                                </div>
                            </div>

                            <div style="display: flex;" class="layui-input-block">
                                <label class="layui-form-label" title="smtp服务器端口">smtp端口：</label>
                                <input type="text" id="smtp-port" name="smtpSeverPort" lay-verify="required"
                                    placeholder="smtp服务器端口" autocomplete="off" class="layui-input"
                                    value="{$smtpSeverPort}">
                            </div>

                        </div>



                    </div>
                </div>

                <div class="layui-tab-content">
                    <label class="layui-form-label" title="用户名">用户名地址：</label>
                    <div class="layui-input-block">
                        <div style="display: flex;" class="layui-box layui-upload-button">
                            <div style="width: 100%;">
                                <input type="text" id="smtp-address" name="smtpSeverUser" lay-verify="required"
                                    placeholder="Sha512加密密钥不可为空 不可逆" autocomplete="off" value="{$smtpSeverUser}"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-tab-content">
                    <label class="layui-form-label" title="密码">登录的密码：</label>
                    <div class="layui-input-block">
                        <div style="display: flex;" class="layui-box layui-upload-button">
                            <div style="width: 100%;">
                                <input type="password" id="smtp-address" name="smtpSeverPass" lay-verify="required"
                                    placeholder="登录的密码" autocomplete="off" value="{$smtpSeverPass}" class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-tab-content">
                    <label class="layui-form-label" title="发件人地址">发件人地址：</label>
                    <div class="layui-input-block">
                        <div style="display: flex;" class="layui-box layui-upload-button">
                            <div style="width: 100%;">
                                <input type="text" id="smtp-address" lay-verify="required" placeholder="发件人地址"
                                    autocomplete="off" value="{$smtpSeverMail}" name="smtpSeverMail"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-tab-content">
                    <label class="layui-form-label" title="发件人昵称">发件人昵称：</label>
                    <div class="layui-input-block">
                        <div style="display: flex;" class="layui-box layui-upload-button">
                            <div style="width: 100%;">
                                <input type="text" id="smtp-address" lay-verify="required" placeholder="发件人昵称"
                                    autocomplete="off" value="{$smtpSeverName}" name="smtpSeverName"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-tab-content">
                    <label class="layui-form-label" title="回复邮件的地址">回复的地址：</label>
                    <div class="layui-input-block">
                        <div style="display: flex;" class="layui-box layui-upload-button">
                            <div style="width: 100%;">
                                <input type="text" id="smtp-address" lay-verify="required" placeholder="回复邮件的地址"
                                    autocomplete="off" value="{$smtpReplyAddress}" name="smtpReplyAddress"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="padding-left: 10px">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal post-form" lay-submit="" type="button"
                        lay-filter="formDemo">
                        立即提交
                    </button>
                    <button class="layui-btn layui-btn-normal test-smtp" lay-submit="" type="button"
                        lay-filter="formDemo">
                        测试邮件
                    </button>
                </div>
            </div>
        </form>
    </div>
    <script src="/static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/admin/js/common.js" type="text/javascript" charset="utf-8"></script>
    <script>
        $("[name='sever_adds']").click(function (e) {
            $sever_adds = $('input:radio:checked').attr("data-mail-address");
            $sever_port = $('input:radio:checked').attr("data-mail-port");
            $('#smtp-address').val($sever_adds);
            $('#smtp-port').val($sever_port);
        })
        $(".test-smtp").click(function (e) {
            var d = {};
            var t = $('form').serializeArray();
            $.each(t, function () {
                d[this.name] = this.value;
            });
            $smtpSeverBodyChar = d['smtpSeverBodyChar'];
            $smtpSeverPort = d['smtpSeverPort'];
            $smtpSeverUser = d['smtpSeverUser'];
            $smtpSeverPass = d['smtpSeverPass'];
            $smtpSeverMail = d['smtpSeverMail'];
            $smtpSeverName = d['smtpSeverName'];
            $smtpReplyAddress = d['smtpReplyAddress'];

            parent.layer.open({
                type: 1,
                title: '收件人地址',
                skin: 'layui-layer-molv',
                closeBtn: 0,
                shadeClose: true,
                shade: false,
                area: ['300px', '180px'],
                content: '<div id="mydiv" style="margin-left:10px;margin-top:10px;"><textarea id="txtReason" style="width:280px;height:70px;resize:none;border-radius:6px;border-color:red;" ></textarea></div>',
                btn: ['确定', '取消']
                , yes: function (index, layero) {
                    var $txtReason = top.$('#txtReason').val();
                    requestData(
                        "/{$useradmin}/Setting/SiteSetting/SmtpSettingTest", {
                        "smtpSeverBodyChar": $smtpSeverBodyChar,
                        "smtpSeverPort": $smtpSeverPort,
                        "smtpSeverUser": $smtpSeverUser,
                        "smtpSeverPass": $smtpSeverPass,
                        "smtpSeverMail": $smtpSeverMail,
                        "smtpSeverName": $smtpSeverName,
                        "smtpReplyAddress": $smtpReplyAddress,
                        "testMailAdds": $txtReason,
                    },
                        (e) => {
                            if (e.code == 200) {
                                alert('测试邮件发送成功 可以保存了')
                            } else {
                                alert('发生意外错误 请查看 控制台中的网络中的 SmtpSettingTest 请求 分析错误原因')
                            }
                            layer.close(loginTips);
                            layer.close(index);
                        }
                    );
                }
            });
        });
        $(".post-form").click(function (e) {
            var d = {};
            var t = $('form').serializeArray();
            $.each(t, function () {
                d[this.name] = this.value;
            });
            $smtpSeverBodyChar = d['smtpSeverBodyChar'];
            $smtpSeverPort = d['smtpSeverPort'];
            $smtpSeverUser = d['smtpSeverUser'];
            $smtpSeverPass = d['smtpSeverPass'];
            $smtpSeverMail = d['smtpSeverMail'];
            $smtpSeverName = d['smtpSeverName'];
            $smtpReplyAddress = d['smtpReplyAddress'];

            requestData(
                "/{$useradmin}/Setting/SiteSetting/SmtpSettingSave", {
                "smtpSeverBodyChar": $smtpSeverBodyChar,
                "smtpSeverPort": $smtpSeverPort,
                "smtpSeverUser": $smtpSeverUser,
                "smtpSeverPass": $smtpSeverPass,
                "smtpSeverMail": $smtpSeverMail,
                "smtpSeverName": $smtpSeverName,
                "smtpReplyAddress": $smtpReplyAddress,
            },
                (e) => {
                    if (e.code == 200) {
                        alert('数据保存成功')
                    } else {
                        ErrorTips(e.code, e.message, e.detail, () => {
                            window.location.reload()
                        });
                    }
                    layer.close(loginTips);
                    layer.close(index);
                }
            );
        });
    </script>
    <iframe id="layui-upload-iframe" class="layui-upload-iframe" name="layui-upload-iframe"></iframe>
</body>

</html>